<template>
  <div id="app">
    <!-- <router-view /> -->
    <router-view v-if="isRouterAlive && !$route.meta.keepAlive"></router-view>
    <keep-alive>
      <router-view v-if="isRouterAlive && $route.meta.keepAlive"></router-view>
    </keep-alive>
  </div>
</template>

<script>
import { getToken } from '@/libs/util'
import routers from '@/router/routers'
export default {
  name: 'App',
  provide () {
    return {
      reload: this.reload
    }
  },
  data () {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload () {
      this.isRouterAlive = false
      this.$nextTick(() => (this.isRouterAlive = true))
    }
  },
  created () {      
       
    this.$store.commit(
      'setShowRouter',
      localStorage.routers
        ? [...routers, ...JSON.parse(localStorage.routers)]
        : routers
    )
  }
}
</script>

<style lang="less">
.size {
  width: 100%;
  height: 100%;
}
html,
body {
  .size;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
#app {
  .size;
}
</style>
